//
//  GLRectangleSurface.m
//  LMPhotoVideoSDK
//
//  Created by Aimar on 16/7/7.
//  Copyright © 2016年 魁钺会. All rights reserved.
//

#import "GLRectangleSurface.h"

@interface GLRectangleSurface () {
    GLfloat        _vertices[12];
    GLfloat        _texcoods[8];
    GLushort       _indices[6];
}

@end

@implementation GLRectangleSurface

- (id)initWithSize:(CGSize)size {
    self = [super init];
    if (self) {
        _indices[0] = 0;
        _indices[1] = 1;
        _indices[2] = 2;
        _indices[3] = 2;
        _indices[4] = 3;
        _indices[5] = 0;

        _vertices[0] = 0;
        _vertices[1] = 0;
        _vertices[2] = 0;
        _vertices[3] = 0;
        _vertices[4] = -size.height;
        _vertices[5] = 0;
        _vertices[6] = size.width;
        _vertices[7] = -size.height;
        _vertices[8] = 0;
        _vertices[9] = size.width;
        _vertices[10] = 0;
        _vertices[11] = 0;
        
        _texcoods[0] = 0.0;
        _texcoods[1] = 0.0;
        _texcoods[2] = 0.0;
        _texcoods[3] = 1.0;
        _texcoods[4] = 1.0;
        _texcoods[5] = 1.0;
        _texcoods[6] = 1.0;
        _texcoods[7] = 0.0;
    }
    return self;
}

#pragma mark GLSurface
- (GLfloat*)getVertices {
    return &_vertices[0];
}

- (GLint)getVertexCount {
    return sizeof(_vertices);
}

- (GLfloat*)getTexcoords {
    return &_texcoods[0];
}

- (GLushort*)getIndices {
    return &_indices[0];
}

- (GLint)getIndexCount {
    return sizeof(_indices);
}

@end
